use data_movers, clear // This dataset contains individual-level data from the population census 2000. These data are not publicly available. Therefore, they are not included in the replication file.


cumul dist_wor5_m, g(cumul_all)
cumul dist_wor5_m if habag == 3, g(cumul_all_higheduc)
cumul dist_wor5_m if habag == 1, g(cumul_all_primeduc)
cumul dist_wor5_m if dist_wm !=. , g(cumul_all_within)
cumul dist_wor5_m if dist_wm !=. & habag == 3, g(cumul_all_within_higheduc)
cumul dist_wor5_m if dist_wm !=. & habag == 1, g(cumul_all_within_primeduc)
cumul dist_wor5_m if dist_wor5_m != 0, g(cumul_movers)
cumul dist_wor5_m if dist_wm !=. & dist_wor5_m != 0, g(cumul_movers_within)
cumul dist_wor5_m if dist_wm !=. & dist_wor5_m != 0 & habag == 3, g(cumul_movers_within_higheduc)
cumul dist_wor5_m if dist_wm !=. & dist_wor5_m != 0 & habag == 1, g(cumul_movers_within_primeduc)

g dist_graph_2 = (int(dist_wor5_m/2))*2

preserve
collapse (min) cumul*, by(dist_graph_2)
graph tw line cumul_all_within dist_graph_2 if dist_graph_2<=80, lc(black) || line cumul_all_within_higheduc dist_graph_2 if dist_graph_2<=80, lc(gray) lp(dash) || line cumul_all_within_primeduc dist_graph_2 if dist_graph_2<=80, lc(gray) lp(".-") ylab(0 (0.2)1) xline(20, lp("-") lc(black)) ytitle("cumulative frequency", size(medsmall)) xtitle("moving distance (km)", size(medsmall)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) legend(col(1) label(1 "all individuals") label(2 "with tertiary education") label(3 "with primary education") order(1 2 3) margin(sides) size(small) position(5) ring(0)) 
graph export fig5a.eps, replace
graph tw line cumul_movers_within dist_graph_2 if dist_graph_2<=80, lc(black) || line cumul_movers_within_higheduc dist_graph_2 if dist_graph_2<=80, lc(gray) lp(dash) || line cumul_movers_within_primeduc dist_graph_2 if dist_graph_2<=80, lc(gray) lp(".-") ylab(0(0.2)1) xline(20, lp("-") lc(black)) ytitle("cumulative frequency", size(medsmall)) xtitle("moving distance (km)", size(medsmall)) graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) legend(col(1) label(1 "all individuals") label(2 "with tertiary education") label(3 "with primary education") order(1 2 3) margin(sides) size(small) position(5) ring(0)) 
graph export fig5b.eps, replace

restore


use data_commuting, clear // This dataset contains individual-level data from the population census 2000. These data are not publicly available. Therefore, they are not included in the replication file.

cumul dist_aort_m, g(cumul_all)
cumul dist_aort_m if dist_wm !=. , g(cumul_all_within)
cumul dist_aort_m if dist_wm !=. & habag == 3, g(cumul_all_within_higheduc)
cumul dist_aort_m if dist_wm !=. & habag == 1, g(cumul_all_within_primeduc)
cumul dist_aort_m if dist_wm !=. & habag != 3, g(cumul_all_within_nohigheduc)
cumul dist_aort_m if aort != 1, g(cumul_inter)
cumul dist_aort_m if dist_wm !=. & aort != 1, g(cumul_inter_within)


g dist_graph_2 = (int(dist_aort_m/2))*2

preserve
collapse (min) cumul*, by(dist_graph_2)
graph tw line cumul_all_within dist_graph_2 if dist_graph_2<=80,  lc(black) || line cumul_all_within_higheduc dist_graph_2 if dist_graph_2 <= 80, lp(dash) lc(gray)  || line cumul_all_within_primeduc dist_graph_2 if dist_graph_2 <= 80, lp(".-") lc(gray) xline(20, lp("-") lc(black)) ytitle("cumulative frequency", size(medsmall)) xtitle("commuting distance (km)", size(medsmall))  graphregion(color(white)) subtitle(,fcolor(white) lcolor(white)) legend(col(1) label(1 "all individuals") label(2 "with tertiary education") label(3 "with primary education") order(1 2 3) margin(sides) size(small) position(5) ring(0))
graph export fig5c.eps, replace
restore
